<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('设置收款账户')" />
    <th:block th:include="include :: datetimepicker-css" />
    </head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-agentDeductions-add">
            <div class="form-group">
                <label class="col-sm-3 control-label">收款账户类型：</label>
                <div class="col-sm-8">
                    <select name="proIsYl" class="form-control m-b" id="proIsYl" onchange="ylType(this)" th:value="*{proIsYl}">
                        <option value="0">服务商</option>
                        <option value="1">团长</option>
                    </select>
                </div>
            </div>
                <input type="hidden" id="isYl" th:value="*{proIsYl}">
            <div id="fu">
                <div class="form-group">
                    <label class="col-sm-3 control-label">收款账户编号：</label>
                    <div class="col-sm-8">
                        <input name="proAgentNum" th:value="*{proAgentNum}" class="form-control" id="agentNum" type="text" readonly>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">收款账户名称：</label>
                    <div class="col-sm-8">
                        <input name="proAgentName" th:value="*{proAgentName}" onclick="selectAgent()"  class="form-control" id="agentName" type="text" required readonly>
                        <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
                    </div>
                </div>
            </div>
            <div id="tuan">
                <div class="form-group">
                    <label class="col-sm-3 control-label">团长编号：</label>
                    <div class="col-sm-8">
                        <input name="proYlId" th:value="*{proYlId}" class="form-control" id="ylId" type="text" readonly>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">团长名称：</label>
                    <div class="col-sm-8">
                        <input name="proYlName" th:value="*{proYlName}" onclick="selectYl()"  class="form-control" id="ylName" type="text" required readonly>
                        <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
                        <input name="proAgentNum1" class="form-control" id="agentNum1" type="hidden" readonly>
                    </div>
                </div>
            </div>
            <input name="id" th:value="*{id}" type="hidden">
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "finance/agentDeductions"
        $("#form-agentDeductions-add").validate({
            focusCleanup: true
        });

        $("input[name='date']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/saveAccount", $('#form-agentDeductions-add').serialize());
            }
        }
        function selectAgent() {
            var url =prefix+ "/selectAgent";
            $.modal.open("选择收款账户" , url, 800, 450);
        }
        function selectYl() {
            var url =prefix+ "/selectYl?ylId="+$("#ylId").val();
            $.modal.open("选择收款团长" , url, 800, 450);
        }
        function ylType(obj) {
            if(obj.value == 1){
                $("#fu").hide()
                $("#tuan").show()
            }else{
                $("#fu").show()
                $("#tuan").hide()
            }
        }
        if($("#isYl").val() == 1){
            $("#fu").hide()
            $("#tuan").show()
            $("#proIsYl").val(1)
        }else{
            $("#fu").show()
            $("#tuan").hide()
        }

    </script>
</body>
</html>